// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.chips;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class InterpretedChip implements Chip {
  final Memory memory;
  final Incrementor incrementor;

  public InterpretedChip(Memory memory, Incrementor incrementor) {
    this.memory = memory;
    this.incrementor = incrementor;
  }
  
  public void update() {
    incrementor.update();
    memory.ADDRESS = incrementor.ADDRESS;
    memory.WR = incrementor.WR;
    memory.REQ = incrementor.REQ;
    if (incrementor.DATA_ACTIVE) memory.DATA = incrementor.DATA;
    
    memory.update();
    if (memory.DATA_ACTIVE) incrementor.DATA = memory.DATA;
  }
}
